package cn.Mmovie.servlet;

import cn.Mmovie.bean.Auditorium;
import cn.Mmovie.bean.Schedule;
import cn.Mmovie.service.AuditoriumService;
import cn.Mmovie.service.CinemaService;
import cn.Mmovie.service.ScheduleService;
import cn.Mmovie.service.impl.AuditoriumServiceImpl;
import cn.Mmovie.service.impl.CinemaServiceImpl;
import cn.Mmovie.service.impl.ScheduleServiceImpl;
import cn.Mmovie.util.PageUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "AdminScheduleListServlet", value = "/admin/schedule_list")
public class AdminScheduleListServlet extends HttpServlet {
    private ScheduleService scheduleService=new ScheduleServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Integer pageNo=1;
        Integer pageSize=10;
        if (request.getParameter("pageNo")!=null&&request.getParameter("pageNo")!=""){
            pageNo=Integer.parseInt(request.getParameter("pageNo"));
        }
        if (request.getParameter("pageSize")!=null&&request.getParameter("pageSize")!=""){
            pageSize=Integer.parseInt(request.getParameter("pageSize"));
        }
        PageUtil<Schedule> page=scheduleService.page(pageNo,pageSize);
        request.setAttribute("page",page);
        request.getRequestDispatcher("/WEB-INF/page/main/schedule_list.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
